
import * as util from 'js/util.js'
import cache from 'gapi/cache.js'
//该方法只用作 绑定成功时获取最新提现方式绑定情况
export let getBindList = (bindTyp,url) =>{               
    util.ajax({
        url:'/wallet/bind_list',
        data:{},
        timeout:10000,
        success:(data) => {
            if(data.code === 200){
                let bind,
                    bindList = data.data,
                    cacheBindList = [],
                    is_bind = false,
                    is_last_use = false;
                for(let m in bindList){
                    if(bindList[m].account_tag === bindTyp){
                    	bindList[m].is_last_use = 1
                    }else{
                    	bindList[m].is_last_use = 0
                    }
                    cacheBindList.push(bindList[m])
                };
                cache.deleteCache('bind_list');
                cache.setCache('bind_list',cacheBindList,10000)
                location.href = `dmmartin://${url}`

            }
        },
        error:function(){
            widget.toast('加载失败请稍后重试')
        }
    }) 
};
//函数节流接受函数和延迟时间
export let throttle = (method, delay) => {
    clearTimeout(window.timer);
    window.timer = setTimeout(() => {
        method();
    },delay);
}